/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.loja.dao;

/**
 *
 * @author Edson
 */
import br.com.loja.control.ConnectionControl;
import br.com.loja.model.Usuario;
import java.sql.*;
import java.sql.PreparedStatement;

public class UsuarioDAO {

	private Connection connection;

	// Long id;
	// String nome;
	// String RG;
	// String cpf;
	// String telefone;
	// String celular;

	public UsuarioDAO() {
		this.connection = ConnectionControl.getConexaoMySQL();
	}

	public void adiciona(Usuario usuario) {
		String sql = "INSERT INTO cliente(cli_nome,cli_RG,cli_cpf,cli_telefone,cli_celular)VALUES(?,?,?,?,?)";
		try {
			try (PreparedStatement stmt = connection.prepareStatement(sql)) {
				stmt.setString(1, usuario.getNome());
				stmt.setString(2, usuario.getRG());
				stmt.setString(3, usuario.getCpf());
				stmt.setString(4, usuario.getTelefone());
				stmt.setString(5, usuario.getCelular());
				stmt.execute();
			}
		} catch (SQLException u) {
			throw new RuntimeException(u);
		}
	}
}
